package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.PageTools;
import model.SFDesk;
import model.FoodDesk;

/**
 * Servlet implementation class ShowFood
 */
public class ShowFood extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowFood() {
        super();
        // TODO Auto-generated constructor stub
    }
    FoodDesk fd= new FoodDesk();
    SFDesk sf= new SFDesk();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 String typeid="";
		try {
			if(request.getParameter("typeid")!=null){
	            typeid=request.getParameter("typeid");
	        }
			 HttpSession session=request.getSession();
			 if(request.getParameter("deskId")!=null){
		            session.setAttribute("deskId", request.getParameter("deskId"));
		        }
			//request.setAttribute("lm",sf.getAllFoodType());
			 String name=request.getParameter("fname");
			 if(request.getParameter("fname")!=null){
		            session.setAttribute("fname", request.getParameter("fname"));
		        }
			String curPage=request.getParameter("curPage");
			Integer curPageInt=1;
			if(curPage!=null && !"".equals(curPage)){
				curPageInt=Integer.parseInt(curPage);
			}
			PageTools lm= fd.getTablePage(typeid,curPageInt);
			request.setAttribute("flm", lm);
			request.getRequestDispatcher("/detail/caidan.jsp").forward(request, response);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
